package com.vector.demo.exception;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
import org.thymeleaf.exceptions.TemplateInputException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 全局异常处理类
 */
@ControllerAdvice
public class MyException {
    @ExceptionHandler(value = {org.thymeleaf.exceptions.TemplateInputException.class} )
    public ModelAndView myException(Exception e) {
        ModelAndView mv = new ModelAndView();
        mv.setViewName("/error/exception");
        return mv;
    }
}